class AudioProcessor extends AudioWorkletProcessor {
    process(inputs, outputs, parameters) {
        const output = outputs[0];
        const len = output[0].length;

        // 从全局缓冲区读取音频数据
        for (let i = 0;< len; i++) {
            const src_idx = (audio_read_cursor + i) & SAMPLE_MASK;
            output[0][i] = audio_samples_L[src_idx]; // 左声道
            output[1][i] = audio_samples_R[src_idx]; // 右声道
        }
        audio_read_cursor = (audio_read_cursor + len) & SAMPLE_MASK;
        return true;
    }
}
registerProcessor('audio-processor', AudioProcessor);
